<?php

DEFINE("HOME_PATH", "../");

require_once(HOME_PATH.'class/class.Entity.php');
require_once(HOME_PATH.'class/class.Topic.php');
require_once(HOME_PATH.'class/class.Utilities.php');


$topic = new Topic();

$topics = null;

if ($_GET != null && isset($_GET)) {
	
	$type = (!Validation::isEmptyString($_GET[type])) ? $_GET[type] : "creationdate";
	if ($type == "creationdate")
		$topics = $topic->getTopicsByCreationDate();
	else if ($type == "owner") {
		$topicVO = new TopicVO();
		$topicVO->user_username = $_GET[u];
		$topic->setVO($topicVO);
		$topics = $topic->getTopicsByOwner();
	}
}

echo json_encode($topics);

// echo Utilities::array2json($topics);


// $topic->getPopularTopics();